{% extends "base.html" %}

{% block header%}
<title>任务列表</title>
{% endblock %}

{% block content %}
{% with model_name='Task' log_detail_url='/pack/log/log_detail' base_url='/pack/task/task' %}
<script type="text/javascript">
    var request_url = '/pack/task/task',
        ColumnDefs = [
            {
                "aTargets": [6],
                "sWidth":"15%",
                "mData": function (source) {
                    var status_str = source[4],
                        _id = source[6];
                    var base_str = "";
                    if (status_str != "停止" && status_str != "中断" && status_str != "已完成"){
                        base_str += "<a href='' onclick='stop{{model_name}}("+ _id +
                            ")'>停止</a> &nbsp;&nbsp;";
                    }
                    return base_str + "<a href='{{log_detail_url}}?model=task&id=" + _id +
                        "' class='openDialog'>详情</a>"
                }
            },
        ];

    function stop{{model_name}}(id){
		if (confirmRandom('确定停止吗?')){
            $.ajax({
               url:'{{base_url}}?state={{stop_state}}&id='+id,
               type:'PUT',
               success:function (result) {
                    if(result){
                       window.location.reload();
                   }else{
                       alert("停止失败！")
                   }
               }
           })
		}
	}
</script>

{% include 'query/plugins/search_form.html' %}

<div >
	<ul id="nav-list" class="nav nav-tabs" >
			  <li class="active"  >
			  	<a>任务列表</a>
			  </li>
	</ul>
	<table  id="{{model_name}}_table" class="table table-bordered datatable" data-toolbar='datatable_toolbar' data-group-by-index='[5]'>
		<thead>
		<tr>
			<th>任务名称</th>
			<th>项目</th>
			<th>分支名称</th>
			<th>进度</th>
            <th>状态</th>
            <th>创建时间</th>
			<th>操作</th>
		</tr>
		</thead>
		<tbody id="{{model_name}}_area"></tbody>
	</table>
</div>
{% endwith %}
{% endblock %}
